package com.hema.auction.adapter;

import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hema.auction.R;
import com.hema.auction.bean.MessageInfo;
import com.hema.auction.utils.Utils;
import com.yqritc.recyclerviewflexibledivider.HorizontalDividerItemDecoration;

import java.util.List;

/**
 * author by john
 */

public class MessageAdapter extends BaseQuickAdapter<MessageInfo, BaseViewHolder> implements HorizontalDividerItemDecoration.MarginProvider {

    private int type;

    public void setType(int type) {
        this.type = type;
    }

    public MessageAdapter(@Nullable List<MessageInfo> data) {
        super(R.layout.layout_message_item, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageInfo item) {
        helper.setText(R.id.tv_message, item.getTitle());
        helper.setText(R.id.tv_date, Utils.timedate(item.getAddtime()));
        if (type == 0) {
            if (item.getIsRead() == 0) {
                //未读
                helper.setVisible(R.id.view_read, true);
            } else {
                helper.setVisible(R.id.view_read, false);
            }
        } else {
            helper.setVisible(R.id.view_read, false);
        }
    }

    @Override
    public int dividerLeftMargin(int position, RecyclerView parent) {
        return 0;
    }

    @Override
    public int dividerRightMargin(int position, RecyclerView parent) {
        return 0;
    }
}
